package com.hzy.seataorder.order.controller;

import com.hzy.common.entities.CommonResult;
import com.hzy.order.entities.Order;
import com.hzy.seataorder.order.service.OrderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author hzy
 * @since 2022/3/8 22:42
 */
@RestController
public class OrderController {

    @Resource
    private OrderService orderService;

    @GlobalTransactional(name = "seata_glo_session", rollbackFor = Exception.class)
    @GetMapping("/order/create")
    public CommonResult<Order> create(Order order){
        orderService.create(order);
        return new CommonResult<Order>(200, "订单创建成功", order);
    }

}
